class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None

class RandomListNode(object):
    def __init__(self, x):
        self.label = x
        self.next = None
        self.random = None

def print_que(top):
    while top != None:
        print(top.val,end='  ')
        top = top.next


def list_toqueue(list):
    top = ListNode(list[0])
    p = top
    for value in list[1:]:
        p.next = ListNode(value)
        p = p.next
    return top